<?php
/**
 * Created by PhpStorm.
 * User: DaibiDaddy
 * Date: 2016/5/24
 * Time: 17:14
 */

namespace App\Base;

use App\BaseExt\Pagination;

class BaseController4Web extends BaseController {

    public $data;

    public function initData()
    {
        $this->data["title"] = "政华教育";
        $this->data["keywords"] = "政华,政华教育,教育";
        $this->data["description"] = "政华教育政华教育政华教育政华教育政华教育政华教育";
        $this->data["rnd"] = "?t=".time();
        $this->data["rnd"] = "?t=v1.0";
    }


    /**
     * @param $base_url
     * @param $total_rows
     * @param int $per_page
     * @return array
     */
    public function creatPage($base_url,$total_rows,$per_page = 10)
    {
        $config['first_url'] = $base_url;
        $config['base_url'] = $base_url;
        $config['total_rows'] = $total_rows;
        $config['per_page'] = $per_page;
//        $config['reuse_query_string'] = TRUE;
//        $config["query_string_segment"] = "page";

        //分页基础配置
        $config['num_links'] = 3;
        $config['first_link'] = '首页';
        $config['prev_link'] = '« 上一页';
        $config['cur_tag_open'] = '<li class="active"><a>';
        $config['cur_tag_close'] = '</a></li>';
        $config['next_link'] = '下一页 »';
        $config['last_link'] = '末页';

        $pageBuilder = new Pagination($config);
        $page =  $pageBuilder->create_links();
        return array(
            "total"     => $total_rows,
            "perPage"   => $per_page,
            "page"      => $page
        );
    }

}
